package com.example.onlinemonitoring.serviceImpl;

import com.example.onlinemonitoring.model.Appalarm;
import com.example.onlinemonitoring.model.common.MyResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.List;

import com.example.onlinemonitoring.Util.tem.CommonAbstractBaseService;
import com.example.onlinemonitoring.dao.AppalarmMapper;
import com.example.onlinemonitoring.service.AppalarmService;

/**
 * @description Appalarm接口实现
 * @author generator
 * @since 2022-04-09 13:25:32
 */
@Service
public class AppalarmServiceImpl extends CommonAbstractBaseService<Appalarm> implements AppalarmService {
    @Autowired
    private AppalarmMapper appalarmmapper;

    public int Update(Appalarm record, Example example) {
        return updateByExample(record, example);
    }

    public int Add(Appalarm record) {
        return insertSelective(record);
    }

    public boolean Exist(Appalarm record, Example example) {
        if (selectCountByExample(example) != 0)
            return true;
        else
            return false;
    }

    public MyResult<Integer> getCount(Example example) {
        List<Integer> list = new ArrayList<>();
        list = appalarmmapper.selectcount();
        MyResult<Integer> result = new MyResult<Integer>();
        if (list.size() != 0) {
            result.setCode(0);
            result.setMsg("success");
            result.setCount(list.size());
            result.setData(list);
        } else {
            result.setCode(1);
            result.setMsg("数据为空");
        }
        return result;
    }
}
